<?php
$connection = mysql_connect("localhost", "root", "") or die("与数据库服务器连接失败");
$db_list = mysql_list_dbs($connection);
echo "数据库列表如下：<br><br>";
while ($row = mysql_fetch_object($db_list)) {
	echo $row->Database . "<br>";
	echo "<hr>";
}
mysql_close($connecton);
?>

<?php


$connection = mysql_connect("localhost", "root", "") or die("与数据库服务器连接失败");
$tb_list = mysql_list_tables("date");
echo "数据库date中的表如下：<br><br>";
while ($row = mysql_fetch_row($tb_list)) {
	echo $row[0] . "<br>";
	echo "<hr>";
}
mysql_close($connecton);
?>


<?php


$connection = mysql_connect("localhost", "root", "") or die("连接服务器失败");

//设置字符编码为GB2312 
mysql_query(" SET NAMES GB2312");

//选择数据库
mysql_select_db("date") or die("不能连接到指定的数据库");

$query = "select * from newslist";

$result = mysql_query($query) or die("查询新闻列表失败");

if ($result == false || @ mysql_num_rows($result) == 0) {
	echo "<li>抱歉，数据库中暂时没有任何信息！</li>";
} else {
	while ($rows = mysql_fetch_array($result)) {
		$news_title = trim($rows["d_title"]);
		$news_date = $rows["d_adddate"];
		$news_id = (int) ($rows["d_id"]);
		echo "<li><a href='NewsRead.php?id=$news_id' target='_blank'>$news_title</a>(" . $news_date. ")</li>";
	}
}

mysql_close($connection);
?>